#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char** argv) {
    time_t t = time(NULL);
    struct tm *tm = localtime(&t);
	char* e=0;
    char date[80];

	char f[1024];
	char cmd[1024];
    strftime(date, sizeof(date), "%Y%m%d", tm);
	if(argc>1){
		strcpy(f,argv[1]);
		e=strrchr(f,'.');
		if(e){
			*e=0;
			e++;
		}
		sprintf(cmd,"copy %s %s%s-%c%c%s",argv[1], f?f:"",date,'A'+tm->tm_hour,e?'.':0,e?e:"");
		printf(cmd);
		system(cmd);
	}else{
		printf("hex-date.exe filename.hex\n\n    ->copy filename.hex filename20241025-A.hex\n    (A=>'A'+hour)\n\nin keil's\n    [User] [After Build/Rebuild] [Run #1].\n\n    [pathto\\hex-date.exe $H@L.hex]\n");
	}
    return 0;
}
